<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>商户新增</title>
<link href="${cssRoot}/css/style.css" rel="stylesheet" type="text/css" />
<link href="${cssRoot}/css/laypage.css" rel="stylesheet" type="text/css" />
<link href="${cssRoot}/js/validate/style/validator.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="${jsRoot}/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="${jsRoot}/js/validate/formValidator-4.0.1.min.js"></script>
<script type="text/javascript" src="${jsRoot}/js/validate/formValidatorRegex.js"></script>
<script type="text/javascript" src="${jsRoot}/js/layer.js"></script>
<script type="text/javascript" src="${jsRoot}/js/laypage.js"></script>
<script type="text/javascript" src="${jsRoot}/js/laytpl.js"></script>

</head>
<body>
    <form id="theform"  onsubmit="return false;">
    <ul class="forminfo">
    	<li><label>账号<b>*</b></label>
    		<input name="account"  id="account" type="text" class="dfinput" style="width:400px;" />
    		<span id="accountTip"></span>
    	</li>
   		<li><label>密码<b>*</b></label>
   		    <input name="password" id="password" type="password" class="dfinput" style="width:400px;" />
   		    <span id="passwordTip"></span></li>
    	<li><input type="submit" class="btn" value="保存"/>
    	    <input type="button" onclick="parent.layer.closeAll();" class="btn" value="关闭"/></li>
    </ul>
    </form>
    
    <script type="text/javascript">
    	$(function() {
			$.formValidator.initConfig({formID:"theform",onError:function(){},  onSuccess:function(){
				$.ajax({
				     type: 'POST',
				     url: 'save.do' ,
				     data: $("#theform").serialize(),
				     success: function(data){
				     	var index = parent.layer.getFrameIndex(window.name);
				     	parent.load_page();
				     	parent.layer.msg('添加成功！');
				     	parent.layer.close(index);//关闭当前窗口
   				     },
   				     error: function(){
				     	layer.msg("添加失败，可能是账号名重复，请修改后重新提交！");
   				     },
				    dataType: "JSON"
				});
    		}});
    		$("#account").formValidator({onShow:"请输入账号名称",onCorrect:"输入正确"}).inputValidator({min:1,onError:"必填字段"});
    		$("#account").ajaxValidator({
				     type: 'GET',
				     url: 'queryAccount.do' ,
				     success: function(data){
				        if(data.status==200){
				         	return true;
				        }
				      	return false;
				     },
				    dataType: "JSON",
				    onError : "账号名重复，请重新填写"
				    
			});
			$("#password").formValidator({onShow:"请输入密码",onCorrect:"输入正确"}).inputValidator({min:6,onError:"密码最少六位"});
    	});
    </script>
</body>
</html>